layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'formSelects','upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;

    laydate.render({
        elem: '#recoveryTime'
    });
    
    // 添加表单验证方法
    form.verify({
        repsw: function (value) {
            if (value !== $('#userForm input[name=password]').val()) {
                return '两次密码输入不一致';
            }
        }
    });

    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var userId = $("#userId").val();
        var recoveryTime = $("#recoveryTime").val();
        var data = {
        		userId: userId,
        		recoveryTime: recoveryTime,
        		titieStatus: '1'
        }
        // 异步请求
        $.ajax({
            url: Feng.ctxPath + "/modular/user/update",
        	data : data,
            type: "post",
            async: false,//关闭异步请求
            dataType: "json",
            success: function (data) {
                if (data.code == 200) {
                	fengj(userId);
                    Feng.success("操作成功！");
                    //传给上个页面，刷新table用
                    // window.parent.location.reload();
                    admin.putTempData('formOk', true);
                    //关掉对话框
                    admin.closeThisDialog();
                } else {
                    Feng.success("操作失败！" + data.message);
                }
            }
            ,
            error: function (data) {
                Feng.error("添加失败！" + data.message)
            }
        });
    });
    
    function fengj(userId){
    	$.ajax({
		    url : "https://www.idjglobalapp.com/app-servce/v1/api/account/invalid-user/" + userId,
		    type : "put",
		    data : $("#userUpdateModal form").serialize(),
		    success : function(result) {
		    
		    }
		});
    }
});